package com.sergiandreplace.kaboom.browser;

import java.io.File;

public class FileType
{
	private String regExp;
	private String description;
	private int icon;
	private int iconForbidden;
	private boolean isDirectory;
	private boolean isComic;
	private int order;
private boolean isUp;
	public FileType(String description, String regExp, int order, int icon, int iconForbidden, boolean isDirectory, boolean isComic)
	{
		this.description=description;
		this.icon = icon;
		this.iconForbidden = iconForbidden;
		this.regExp = regExp;
		this.isDirectory = isDirectory;
		this.setIsComic(isComic);
		this.setUp(false);
		this.setOrder(order);
		

	}
	public FileType(String description, String regExp, int order, int icon, int iconForbidden, boolean isDirectory, boolean isComic, boolean isUp)
	{
		this.description=description;
		this.icon = icon;
		this.iconForbidden = iconForbidden;
		this.regExp = regExp;
		this.isDirectory = isDirectory;
		this.setIsComic(isComic);		
		this.setUp(isUp);
		this.setOrder(order);

	}
	public boolean isFileType(String path, String filename)
	{
		String fullName = path + (!path.matches(".*/") ? "/" : "") + filename;
		if (new File(fullName).isDirectory() == isDirectory)
			return fullName.matches(regExp);
		else
			return false;
	}

	public String getRegExp()
	{
		return regExp;
	}

	public void setRegExp(String regExp)
	{
		this.regExp = regExp;
	}

	public String getDescription()
	{
		return description;
	}

	public void setDescription(String description)
	{
		this.description = description;
	}

	public int getIcon()
	{
		return icon;
	}

	public void setIcon(int icon)
	{
		this.icon = icon;
	}

	public int getIconForbidden()
	{
		return iconForbidden;
	}

	public void setIconForbidden(int iconForbidden)
	{
		this.iconForbidden = iconForbidden;
	}

	public boolean isDirectory()
	{
		return isDirectory;
	}

	public void setDirectory(boolean isDirectory)
	{
		this.isDirectory = isDirectory;
	}

	public int getIcon(String path, String filename)
	{
		String fullName = path + (!path.matches(".*/") ? "/" : "") + filename;
		if (new File(fullName).canRead())
			return icon;
		else
			return iconForbidden;

	}

	public void setIsComic(boolean isComic)
	{
		this.isComic = isComic;
	}

	public boolean isComic()
	{
		return isComic;
	}
	public void setUp(boolean isUp)
	{
		this.isUp = isUp;
	}
	public boolean isUp()
	{
		return isUp;
	}
	public void setOrder(int order)
	{
		this.order = order;
	}
	public int getOrder()
	{
		return order;
	}

}
